package com.shitu.soulemo.a;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.shitu.base.BaseFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by majie on 2018/3/20.
 */

public class AAdapter extends FragmentStatePagerAdapter {
    private List<BaseFragment> list = new ArrayList<>();

    public AAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (position == -1) {//隐藏分类按钮
            return "分类";
        } else if (position == 0) {
            return "推荐";
        } else if (position == 1) {
            return "服务";
        } else if (position == 2) {
            return "物品";
        } else if (position == 3) {
            return "信息";
        }
        return "";
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Fragment getItem(int i) {
        return list.get(i);
    }

    public void addData(BaseFragment fragment) {
        list.add(fragment);
    }

    public void clearData() {
        list.clear();
    }
}
